<html>
<head><meta charset="utf-8"><title>let-else typeck · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/let-else.20typeck.html">let-else typeck</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247153100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/let-else%20typeck/near/247153100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/let-else.20typeck.html#247153100">(Jul 26 2021 at 00:32)</a>:</h4>
<p>I am working on implementing let-else. Should I expand with <code>let ! =</code> or add a special case to <code>check_match</code> in typeck? This is <em>very</em> similar to <a href="https://github.com/rust-lang/rust/issues/60707">#60707</a>. I know <span class="user-mention" data-user-id="119009">@eddyb</span> has said "Do not use desugaring information to affect the semantics, only adjust diagnostics.", and I can see the appeal of that, but at the same time I wonder - adding a restriction to typeck does not change semantics of the HIR for correct code. Isn't it better to use a HIR structure that is minimal and correct and allow typeck to be responsible for desugaring-specific type restrictions? <span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="255061">@Léo Lanteri Thauvin</span></p>



<a name="247262797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/let-else%20typeck/near/247262797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/let-else.20typeck.html#247262797">(Jul 26 2021 at 21:06)</a>:</h4>
<p>I think <code>if</code>s are no longer lowered to <code>match</code> now?</p>



<a name="247263595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/let-else%20typeck/near/247263595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/let-else.20typeck.html#247263595">(Jul 26 2021 at 21:10)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.ExprKind.html#variant.If">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.ExprKind.html#variant.If</a></p>



<a name="247264036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/let-else%20typeck/near/247264036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/let-else.20typeck.html#247264036">(Jul 26 2021 at 21:12)</a>:</h4>
<p>You're right. I think the same approach is used for <code>while let</code> and that's why I found this <a href="https://github.com/rust-lang/rust/blob/fc24bcead1d401ae061538d011e4a319c4195b56/compiler/rustc_typeck/src/check/_match.rs#L78">FIXME</a>.</p>



<a name="247273760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/let-else%20typeck/near/247273760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/let-else.20typeck.html#247273760">(Jul 26 2021 at 22:48)</a>:</h4>
<p>(You probably meant <code>while</code>)</p>



<a name="247273936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/let-else%20typeck/near/247273936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/let-else.20typeck.html#247273936">(Jul 26 2021 at 22:50)</a>:</h4>
<p>I think that ideally the desugar would be enough that HIR/typeck wouldn't need to know anything new, the same way they don't know about things like <code>?</code>.</p>
<p>Whether that's practical, though, I don't know.  My naïve guess would be that either it's a pure desugar, or it's a new thing in HIR (and thus typeck too) and not a desugar at all.</p>



<a name="247274757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/let-else%20typeck/near/247274757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/let-else.20typeck.html#247274757">(Jul 26 2021 at 23:02)</a>:</h4>
<p>Another idea is to use a type ascription instead of a <code>let</code> statement, though I'm not sure it would work, I don't know the exact semantics of type ascriptions</p>



<a name="247274831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/let-else%20typeck/near/247274831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/let-else.20typeck.html#247274831">(Jul 26 2021 at 23:03)</a>:</h4>
<p>FWIW type ascriptions in HIR are <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.ExprKind.html#variant.Type"><code>ExprKind::Type</code></a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>